/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
 */

package com.huawei.rpc.config;

import com.huawei.rpc.common.prorocol.HessianSerializeMessageProrocol;
import com.huawei.rpc.common.prorocol.JavaSerializeMessageProtocol;
import com.huawei.rpc.common.prorocol.MessageProtocol;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @Author Lijl
 * @ClassName ProtocolProperties
 * @Description 协议配置
 * @Date 2022/2/15 17:50
 * @Version 1.0
 */
@ConfigurationProperties(prefix = "spring.rpc.protocol")
public class ProtocolProperties {
    private final String NAME = "hessian";
    private final int PORT = 9527;
    private String name = NAME;
    private int port = PORT;
    private MessageProtocol messageProtocol = new HessianSerializeMessageProrocol();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        //设置支持的协议
        if (name!=null||"java".equals(name)){
            messageProtocol = new JavaSerializeMessageProtocol();
        }
        this.name = name;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public MessageProtocol getMessageProtocol() {
        return messageProtocol;
    }
}
